how to create method in dictionary